/**
 * 这其实是关联任务组件，给mr和commit详情用的
 * 原来用了uiless坑位的方式，但有bug，改成直接引uiless-associate-panel组件了s
 */

import React from 'react';
import track from 'utils/track';
import UILessComponent from '@alife/yunxiao-associate-panel';
import intl from '../../locale';
import { getFeature } from 'utils/features';
export default class UILessPluginForCode extends React.Component {
  render() {
    const { associatePanelOptions = {}, identifier, plugin, container, ...others } = this.props;
    if (!getFeature('project.associated_projex_workitem')) {
      return null;
    }
    return (
      <UILessComponent
        plugin={{
          type: 'task', // 对应的插件类型
          // type: 'codeup-task', // 对应的插件类型
          appId: window.UILessConfig.appId,
          label:
            associatePanelOptions.associatePanelLabel ||
            intl.get({
              id: 'code-assets.components.UILessPluginForCode.AssociatedContent',
              defaultMessage: '关联内容',
            }),
          newCommit: container?.newCommit,
          tbHost: window.UILessConfig.tbHost,
          ...plugin,
        }}
        container={{
          type: 'codeup', // 容器类型
          projectId: window.FORCE.pathResource.id, // 非必填，任务归属的项目ID
          ...container,
        }}
        // style: { padding: '0 20px' },
        uiless_config={{
          ...window.UILessConfig,
          codeupTrack: track,
        }}
        {...others}
        {...associatePanelOptions}
      />
    );
  }
}
